home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / utils / tlayr10 / basicobj.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-19  |  5.1 KB  |  200 lines

  1. // TILE LAYER v1.0
  2. // -------------------------------------------------
  3.  
  4. // Interface objects
  5. // -------------------------------------------------
  6.  
  7. #define ASK_SAVE        1
  8. #define DONT_ASK        0
  9.  
  10. #define UP_PAN          24
  11. #define DOWN_PAN        25
  12. #define RIGHT_PAN       26
  13. #define LEFT_PAN        27
  14.  
  15. class hot_area_group;
  16.  
  17. // --------------------------
  18. // Class hot_area.
  19. // An hot_area is simply an area on the screen that
  20. // "reacts" to mouse button click
  21. // --------------------------
  22.  
  23. class hot_area {
  24.  
  25.  friend hot_area_group;
  26.  
  27. protected:
  28.  hot_area_group *owner;
  29.  unsigned xpos, ypos;
  30.  unsigned xsize, ysize;
  31.  
  32. public:
  33.  hot_area(unsigned, unsigned, unsigned, unsigned);
  34.  virtual ~hot_area() {};
  35.  virtual void draw();
  36.  virtual int is_mouse_up();
  37.  virtual void on_mouseup() {};
  38. };
  39.  
  40. // ---------------------------
  41. // Class hot_area_group
  42. // Is used simplify the management of hot_area classes
  43. // ---------------------------
  44.  
  45. class hot_area_group {
  46.  hot_area **hot_areas;
  47.  
  48. public:
  49.  hot_area_group(hot_area **);
  50.  virtual ~hot_area_group();
  51.  virtual void draw();
  52.  virtual int  is_mouse_up();
  53.  virtual void on_mouseup() {};
  54. };
  55.  
  56. // -------------------------
  57. // Class command_target
  58. // Is an object that "reacts" to command
  59. // generated by buttons
  60. // -------------------------
  61.  
  62. class command_target {
  63.  
  64. public:
  65.  virtual int handle_command(unsigned );
  66. };
  67.  
  68. // -------------------------
  69. // Class control
  70. // Base class for the button and pan_control classes
  71. // It implements the reaction to mouse click and the
  72. // transmission of the generated command to the command_target
  73. // -------------------------
  74.  
  75. class control: public hot_area {
  76.  command_target *target;
  77. protected:
  78.  unsigned command;
  79.  
  80. public:
  81.  control(unsigned, unsigned, unsigned, unsigned, unsigned, command_target * );
  82.  virtual void pressed();
  83.  virtual void on_mouseup();
  84. };
  85.  
  86. // --------------------------
  87. // Class button
  88. // A simple child of control base class.
  89. // Class button is a control with a label and different
  90. // drawing methods ( draw() and pressed() ). The base mechanism are
  91. // inherited.
  92. // --------------------------
  93.  
  94. class button: public control {
  95.  char *label;
  96.  
  97. public:
  98.  button(unsigned, unsigned, char *, unsigned, command_target * );
  99.  
  100.  virtual void pressed();
  101.  virtual void draw();
  102. };
  103.  
  104. // --------------------------
  105. // Class pan_control
  106. // Another child of control base class.
  107. // Class pan_control is a control with a different
  108. // drawing methods. You have to specify the direction
  109. // of the panning control, the proper command will be
  110. // generated and trasmitted to target.
  111. // --------------------------
  112.  
  113. class pan_control: public control {
  114.  unsigned direction;
  115.  
  116. public:
  117.  pan_control(unsigned, unsigned, command_target *, unsigned);
  118.  
  119.  virtual void pressed();
  120.  virtual void draw();
  121. };
  122.  
  123. // ---------------------------
  124. // Class tile_set
  125. // One of the most complex class used in this application.
  126. // It is an hot_area because it reacts to mouse click and a 
  127. // command_target because it respond to commands given by the
  128. // tile set control buttons. ( See the file TILELAYR.DOC for further
  129. // informations ).
  130. // Class tile_set holds all the bitmaps of the tiles, it has methods
  131. // for drawing tile on screen, for loading a new set.
  132. // ---------------------------
  133.  
  134. class tile_set: public hot_area, public command_target {
  135.  friend world_editor;
  136.  
  137.  char *set_name;
  138.  unsigned char tile_x, tile_y;
  139.  char far **tiles_bitmaps;
  140.  unsigned no_of_tiles, cur_tile;
  141.  
  142. public:
  143.  tile_set(unsigned, unsigned );
  144.  virtual ~tile_set();
  145.  void destroy_tiles();
  146.  int load_set(char *);
  147.  int put_tile(unsigned, unsigned, unsigned);
  148.  
  149.  virtual void draw();
  150.  virtual void on_mouseup();
  151.  
  152.  virtual int handle_command(unsigned );
  153.  
  154.  friend void Drawcursor();
  155. };
  156.  
  157. // --------------------------------
  158. // The function Drawcursor() is a friend
  159. // of Class tile_set and Class world_editor in order to
  160. // simplify the drawing of the mouse cursor.
  161. // See file TILEMAIN.C where the function is implemented.
  162. // --------------------------------
  163.  
  164. // --------------------------------
  165. // Class world_editor
  166. // Probably the most complex class of this application.
  167. // Class world_editor reacts to mouse click and commands generated by
  168. // edit window scroll buttons and menu buttons, see file TILELAYR.DOC
  169. // for more informations.
  170. // All the work of the application is done by the methods of this class.
  171. // --------------------------------
  172.  
  173. class world_editor: public hot_area, public command_target {
  174.  char far *world;
  175.  unsigned line_length, no_lines;
  176.  unsigned cur_x, cur_y, buffer_offset;
  177.  unsigned char modified;
  178.  tile_set *world_tiles;
  179.  
  180. public:
  181.  world_editor(tile_set *, unsigned, unsigned );
  182.  virtual ~world_editor();
  183.  int load_tiles();
  184.  int load_world();
  185.  int save_world(unsigned = 0);
  186.  void scroll(unsigned );
  187.  void redim(unsigned= 0, unsigned= 0);
  188.  void show_info();
  189.  
  190.  virtual void draw();
  191.  virtual void Redraw();
  192.  virtual void on_mouseup();
  193.  
  194.  virtual int handle_command(unsigned );
  195.  friend void Drawcursor();
  196. };
  197.  
  198. // -------------------------------------------------
  199.  
  200.